package com.lanou.timeline.reply.service.impl;

import com.lanou.timeline.reply.entity.TimelineReply;
import com.lanou.timeline.reply.mapper.TimelineReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TimelineReplyServiceImpl {
    @Autowired
    private TimelineReplyMapper timelineReplyMapper;

    public void replyComment(TimelineReply timelineReply) {
        long addtime = (new Date().getTime())/1000;
        timelineReply.setAddtime(addtime);
        timelineReplyMapper.replyComment(timelineReply);
    }

    public List<TimelineReply> showReply(String tagCommentId) {
        return timelineReplyMapper.showReply(tagCommentId);
    }

    public void operaReply(String timelineReplyId, Integer uid) {
        if (timelineReplyMapper.selectReply(timelineReplyId,uid) == 1){
            timelineReplyMapper.delectReply(timelineReplyId);
        }else {
            int report = timelineReplyMapper.selectReplyReport(timelineReplyId) +1;
            timelineReplyMapper.reportReply(timelineReplyId,report);
        }
    }
}
